<?php


namespace app\mobile\controller;


use think\Controller;

class Personal extends Controller
{
    public function index()
    {
        $member_id = session('member_id');
        $member = db('member')->find($member_id);
        $this->assign([
            'member' => $member
        ]);
        if($this->request->post()){
            $param = $this->request->param();
            $data = [
                'nickname' => $param['nickname'],
                'mobile' => $param['mobile'],
                'pen_name' => $param['pen_name'],
                'descr' => $param['descr'],
                'is_author' => $param['is_author'],
                'is_auto' => $param['is_auto'],
            ];
            if($data['is_author'] == 0){
                $data['pen_name'] = null;
            }
//            dump($data);die;
            $id = $param['id'];
            $res = db('member')->where('id',$id)->update($data);
            if(!$res) return ['state' => -1,'msg' => '系统错误，请稍后再试!!!'];
            return ['state' => 200,'msg' => '修改成功'];
        }
        return view('index');
    }
}